﻿using Aspose.Cells;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FileConvert.AsposeOper
{
    public class ExcelFile
    {
        public ExcelFile(string fromFile, string toFile)
        {
            _formFile = fromFile;
            _toFile = toFile;
            Aspose.Cells.FontConfigs.SetFontFolders(FontClass.GetSystemFontList().ToArray(), true);
            wbk = new Aspose.Cells.Workbook(_formFile);
            if(wbk.IsLicensed==false)
            { 
                AsposeRegister.Register_Cells();
            }
        }
        ~ExcelFile()
        {
            wbk.Dispose();
        }

        Aspose.Cells.Workbook wbk;
        private string _formFile = "";
        private string _toFile = "";
        public void ConvertToPdf()
        {
            wbk.Save(_toFile, SaveFormat.Pdf);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public void ConvertToXPS()
        {
            wbk.Save(_toFile, SaveFormat.XPS);
        }


        public void ConvertToHTML()
        {
            wbk.Save(_toFile, SaveFormat.Html);
        }

        public void ConvertToCSV()
        {
            wbk.Save(_toFile, SaveFormat.CSV);
        }

    }
}
